# -*- coding: utf-8 -*-
# !/usr/bin/env python
import arrow


def to_date(date):
    return arrow.get(date, "YYYY-MM-DD")


def date_diff(start, end):
    """计算时间差多少天"""
    start = to_date(start)
    end = to_date(end)
    return (end - start).days


def to_str(date):
    return str(date)[:10]


def get_day(date, num):
    """计算当前时间的后N天"""
    return str(to_date(date).shift(days=num))[:10]


def get_month(date, num):
    """计算当前时间N月后的今天"""
    return str(to_date(date).shift(months=num))[:10]


def get_month_first(date, num):
    """计算当前时间N月后的月第一天"""
    return str(to_date(date).shift(months=num))[:8] + '01'


def get_year(date, num):
    """计算当前时间N年后的今天"""
    return str(to_date(date).shift(years=num))[:10]


def get_year_first(date, num):
    """计算当前时间N年后的年第一天"""
    return str(to_date(date).shift(years=num))[:8] + '01'
